/**
  其他境外交流项目申请-学生视角
*/
<template>
    <div class="project-application-container">
        <!-- 列表开始 -->
        <div v-if="indexKey === 1">
            <el-card
                shadow="never"
                v-loading="loading"
                body-style="padding: 24px;"
                class="card-margin"
            >
                <h1 class="condition-title">{{$t('projectApplication.otherOverseasExchangeList')}}</h1>
                <div class="edu-opertion-bar sub-title">
                    <div class="float-right" style="display: flex;">
                        <el-button
                            v-if="permitToApply"
                            type="primary"
                            @click="stuApplyCommunicate()"
                        >{{$t('externamExchangeBase.apply')}}</el-button>
                        <el-button
                            v-if="permitToDeleteChoosed"
                            type="danger"
                            @click="stuDeleteChooseInfo()"
                        >{{$t('common.btn.delete')}}</el-button>
                    </div>
                </div>
                <edu-table
                    :pagination="false"
                    :order="true"
                    :tooltipEffect="tooltipEffect"
                    stripe
                    :data="dataList"
                    size="mini"
                    @selection-change="handleSelectionChange"
                >
                    <edu-table-column
                        :label="$t('externamExchangeBase.studentId')"
                        prop="studentId"
                    ></edu-table-column>
                    <edu-table-column
                        :label="$t('externamExchangeBase.studentName')"
                        prop="studentName"
                    ></edu-table-column>
                    <edu-table-column
                        :label="$t('externamExchangeBase.college')"
                        prop="studentFacultyName"
                    ></edu-table-column>
                    <edu-table-column
                        :label="$t('externamExchangeBase.profession')"
                        prop="studentProfessionName"
                    ></edu-table-column>
                    <edu-table-column
                        :label="$t('projectManage.projectSubCategory')"
                        prop="projectSubCategoryName"
                        width="100"
                    ></edu-table-column>
                    <edu-table-column
                        :label="$t('projectManage.projectName')"
                        prop="projectMngmtName"
                    ></edu-table-column>
                    <edu-table-column
                        :label="$t('interdisciplinaryManagement.country')"
                        prop="projectNationName"
                    >
                        <template slot-scope="scope">
                            <div v-if="scope.row.changes.length > 0">
                                <span
                                    v-if="scope.row.changes[0].nationChanged"
                                    style="color: red;"
                                >{{ scope.row.changes[0].countryRegion }}</span>
                                <span v-else>{{ scope.row.projectNationName }}</span>
                            </div>
                            <div v-else>{{ scope.row.projectNationName }}</div>
                        </template>
                    </edu-table-column>
                    <edu-table-column
                        :label="$t('externamExchangeBase.cooperativeUniversity')"
                        prop="projectCollegeCn"
                    >
                        <template slot-scope="scope">
                            <div v-if="scope.row.changes.length > 0">
                                <span
                                    v-if="scope.row.changes[0].collegeChanged"
                                    style="color: red;"
                                >{{ scope.row.changes[0].cooperateUniversity }}</span>
                                <span v-else>{{ scope.row.projectCollegeCn }}</span>
                            </div>
                            <div v-else>{{ scope.row.projectCollegeCn }}</div>
                        </template>
                    </edu-table-column>
                    <edu-table-column
                        :label="$t('projectApplication.projectStartTime')"
                        prop="projectStartTime"
                        width="110"
                    >
                        <template slot-scope="scope">
                            <div v-if="scope.row.changes.length > 0">
                                <span
                                    v-if="scope.row.changes[0].startTimeChanged"
                                    style="color: red;"
                                >{{ scope.row.changes[0].projectStartTime }}</span>
                                <span v-else>{{ scope.row.projectStartTime }}</span>
                            </div>
                            <div v-else>{{ scope.row.projectStartTime }}</div>
                        </template>
                    </edu-table-column>
                    <edu-table-column
                        :label="$t('projectApplication.projectEndTime')"
                        prop="projectEndTime"
                        width="110"
                    >
                        <template slot-scope="scope">
                            <div v-if="scope.row.changes.length > 0">
                                <span
                                    v-if="scope.row.changes[0].endTimeChanged"
                                    style="color: red;"
                                >{{ scope.row.changes[0].projectEndTime }}</span>
                                <span v-else>{{ scope.row.projectEndTime }}</span>
                            </div>
                            <div v-else>{{ scope.row.projectEndTime }}</div>
                        </template>
                    </edu-table-column>
                    <edu-table-column
                        :label="$t('projectApplication.realStartTime')"
                        prop="realStartTime"
                        width="110"
                    >
                        <template slot-scope="scope">
                            <span v-if="scope.row.back">{{ scope.row.back.realStartTime }}</span>
                        </template>
                    </edu-table-column>
                    <edu-table-column
                        :label="$t('projectApplication.realEndTime')"
                        prop="realEndTime"
                        width="110"
                    >
                        <template slot-scope="scope">
                            <span v-if="scope.row.back">{{ scope.row.back.realEndTime }}</span>
                        </template>
                    </edu-table-column>
                    <edu-table-column
                        :label="$t('projectApplication.projectStudyAbroadContent')"
                        prop="projectStudyAbroadContent"
                    ></edu-table-column>
                    <!-- 出国申请审核状态 -->
                    <edu-table-column
                        :label="$t('projectApplication.goAbroadAuditStatus')"
                        prop="applyStatus"
                        width="135"
                    >
                        <template slot-scope="scope">
                            <el-tag
                                :type="scope.row.applyStatus | getApplyStatusType"
                            >{{ scope.row.applyStatus | goAbroadAuditStatus }}</el-tag>
                        </template>
                    </edu-table-column>
                    <!-- 是否录取 -->
                    <edu-table-column
                        :label="$t('projectApplication.participantPass')"
                        prop="participantPass"
                    >
                        <template slot-scope="scope">
                            <el-tag
                                v-if="scope.row.projectSubCategory === 6 && (scope.row.participantPass === 1 || scope.row.participantPass === 2 || scope.row.participantPass === 3)"
                                :type="scope.row.participantPass | getAdmissionType"
                            >{{ scope.row.participantPass | participantPass }}</el-tag>
                        </template>
                    </edu-table-column>
                    <!-- 下一级审批人 -->
                    <!-- <edu-table-column :label="$t('externamExchangeBase.nextAuditPerson')">
            <template slot-scope="scope">
              <span v-if="permitToBatchPass">{{scope.row.approverNameCopy}}</span>
              <span v-else>{{scope.row.approverName}}</span>
            </template>
                    </edu-table-column>-->
                    <edu-table-column
                        :label="$t('externamExchangeBase.nextAuditPerson')"
                        prop="approverNameCopy"
                        width="110"
                    ></edu-table-column>
                    <!-- 操作 -->
                    <edu-table-column
                        :label="$t('common.text.operation')"
                        prop="operation"
                        fit
                        width="130"
                    >
                        <template slot-scope="scope">
                            <el-button
                                v-if="permitToSelectGoAbroad"
                                type="text"
                                @click="selectGoAbroad(scope.row)"
                            >{{$t('message.Look')}}</el-button>
                            <!-- 出国申请审核状态为草稿/驳回可编辑,报销/报道操作展示为空 -->
                            <el-button
                                v-if="permitToEditGoAbroad && (scope.row.applyStatus === 1 || scope.row.applyStatus === 5) && !scope.row.back"
                                type="text"
                                @click="editGoAbroad(scope.row)"
                            >{{$t('common.btn.edit')}}</el-button>
                            <!-- 出国申请审核状态为草稿/驳回可删除,报销/报道操作展示为空 -->
                            <el-button
                                v-if="permitToDeleteGoAbroad && (scope.row.applyStatus === 1 || scope.row.applyStatus === 5) && !scope.row.back"
                                type="text"
                                @click="deleteGoAbroad(scope.row)"
                            >{{$t('common.btn.delete')}}</el-button>
                            <!-- 出国申请审核状态为已提交可撤销,报销/报道操作展示为空 -->
                            <el-button
                                v-if="permitToRevokeGoAbroad && scope.row.applyStatus === 2 && !scope.row.back"
                                type="text"
                                @click="revokeGoAbroad(scope.row)"
                            >{{$t('externamExchangeBase.revoke')}}</el-button>
                        </template>
                    </edu-table-column>
                    <!-- 回国报销状态 -->
                    <edu-table-column
                        :label="$t('projectApplication.returnHomeReimbursement')"
                        prop="returnHomeReimbursement"
                        width="110"
                    >
                        <template slot-scope="scope">
                            <el-tag
                                v-if="scope.row.back"
                                :type="scope.row.back.applyStatus | getApplyStatusType"
                            >{{ scope.row.back.applyStatus | returnHomeReimbursement }}</el-tag>
                        </template>
                    </edu-table-column>
                    <!-- 报销下一级审批人 -->
                    <edu-table-column
                        :label="$t('externamExchangeBase.baoxiaoNextAuditPerson')"
                        prop="approverName"
                        width="135"
                    >
                        <template slot-scope="scope">
                            <span v-if="scope.row.back">{{ scope.row.back.approverName }}</span>
                        </template>
                    </edu-table-column>
                    <!-- 报销/报道操作 -->
                    <edu-table-column
                        :label="$t('projectApplication.baoxiaoAndBaoDaoOperate')"
                        fit
                        width="200"
                    >
                        <template slot-scope="scope">
                            <!-- 国家公派-回国报道操作开始 -->
                            <span v-if="scope.row.projectSubCategory === 6">
                                <!-- 国家公派-出国审核审核通过，且录取状态为已录取，报销无审核状态，新增了回国报道,产生报道审核状态 -->
                                <el-button
                                    v-if="permitToSelectReturnHomeBD && scope.row.applyStatus === 4 && scope.row.participantPass === 1 && scope.row.back && scope.row.back.applyStatus"
                                    type="text"
                                    @click="selectReturnHome(scope.row)"
                                >{{ $t('message.Look') }}</el-button>
                                <!-- 国家公派-出国审核审核通过，且录取状态为已录取，报销无审核状态，可新增回国报道 -->
                                <el-button
                                    v-if="permitToAddReturnHomeBD && scope.row.applyStatus === 4 && scope.row.participantPass === 1 && !scope.row.back"
                                    type="text"
                                    @click="addGoHomeReport(scope.row)"
                                >{{ $t('common.btn.add') }}</el-button>
                                <!-- 国家公派-出国审核审核通过，且录取状态为已录取，回国报道/报销审核状态为草稿或者已驳回，可编辑回国报道 -->
                                <el-button
                                    v-if="permitToEditReturnHomeBD && scope.row.applyStatus === 4 && scope.row.participantPass === 1 && (scope.row.back && (scope.row.back.applyStatus === 1 || scope.row.back.applyStatus === 5))"
                                    type="text"
                                    @click="editReturnHome(scope.row)"
                                >{{$t('common.btn.edit')}}</el-button>
                            </span>
                            <!-- 回国报道操作结束 -->
                            <!-- 短期访学-回国报销操作开始 -->
                            <span v-if="scope.row.projectSubCategory === 7">
                                <el-button
                                    v-if="permitToSelectReturnHomeBX && scope.row.applyStatus === 4 && scope.row.back"
                                    type="text"
                                    @click="selectReturnHome(scope.row)"
                                >{{ $t('message.Look') }}</el-button>
                                <!-- 短期访学-出国审核审核通过，报销无审核状态，可申请回国报销 -->
                                <el-button
                                    v-if="permitToAddReturnHomeBX && scope.row.applyStatus === 4 && !scope.row.back"
                                    type="text"
                                    @click="addGoHomeReport(scope.row)"
                                >{{ $t('externamExchangeBase.apply') }}</el-button>
                                <!-- 短期访学-出国审核审核通过，回国报销审核状态为草稿或者已驳回，可编辑回国报销 -->
                                <el-button
                                    v-if="permitToEditReturnHomeBX && scope.row.applyStatus === 4 && (scope.row.back && (scope.row.back.applyStatus === 1 || scope.row.back.applyStatus === 5))"
                                    type="text"
                                    @click="editReturnHome(scope.row)"
                                >{{$t('common.btn.edit')}}</el-button>
                                <!-- 短期访学-出国审核审核通过，回国报销状态为已提交,可撤销 -->
                                <el-button
                                    v-if="permitToRevokeReturnHomeBX && scope.row.applyStatus === 4 && scope.row.back && scope.row.back.applyStatus === 2"
                                    type="text"
                                    @click="revokeReturnHome(scope.row)"
                                >{{$t('externamExchangeBase.revoke')}}</el-button>
                            </span>
                            <!-- 回国报销操作结束 -->
                        </template>
                    </edu-table-column>
                </edu-table>
                <el-row type="flex" class="row-bg" justify="end">
                    <el-col>
                        <el-pagination
                            @size-change="handleSizeChange"
                            @current-change="handleCurrentChange"
                            :current-page="queryForm.pageNum_"
                            :page-sizes="[20, 40, 80, 100]"
                            :page-size="queryForm.pageSize_"
                            layout="total, sizes, prev, pager, next, jumper"
                            :total="queryForm.total_"
                            style="float:right;margin-top:10px"
                        ></el-pagination>
                    </el-col>
                </el-row>
            </el-card>
        </div>
        <!-- 列表结束 -->
        <!-- 申请出国开始 -->
        <div v-if="indexKey === 2">
            <go-abroad-for-apply @change-project-index="changeProjectIndex"></go-abroad-for-apply>
        </div>
        <!-- 申请出国结束 -->
        <!-- 查看出国开始 -->
        <div v-if="indexKey === 3">
            <go-abroad-for-select :applyId="applyId" @change-project-index="changeProjectIndex"></go-abroad-for-select>
        </div>
        <!-- 查看出国结束 -->
        <!-- 编辑出国开始 -->
        <div v-if="indexKey === 4">
            <go-abroad-for-edit :applyId="applyId" @change-project-index="changeProjectIndex"></go-abroad-for-edit>
        </div>
        <!-- 编辑出国结束 -->
        <!-- 回国新增开始 -->
        <div v-if="indexKey === 5">
            <return-home-add
                :applyId="applyId"
                :backId="backId"
                :projectSubCategory="projectSubCategory"
                :projectStartTime="projectStartTime"
                :projectEndTime="projectEndTime"
                @change-project-index="changeProjectIndex"
            ></return-home-add>
        </div>
        <!-- 回国新增结束 -->
        <!-- 回国编辑开始 -->
        <div v-if="indexKey === 6">
            <return-home-edit
                :applyId="applyId"
                :backId="backId"
                :projectSubCategory="projectSubCategory"
                :projectStartTime="projectStartTime"
                :projectEndTime="projectEndTime"
                @change-project-index="changeProjectIndex"
            ></return-home-edit>
        </div>
        <!-- 回国编辑结束 -->
        <!-- 回国查看开始 -->
        <div v-if="indexKey === 7">
            <return-home-select
                :tabTitle="tabTitle"
                :backId="backId"
                :showProcess="showProcess"
                :projectStartTime="projectStartTime"
                :projectEndTime="projectEndTime"
                @change-project-index="changeProjectIndex"
            ></return-home-select>
        </div>
        <!-- 回国查看结束 -->
        <edu-export-dialog
            :disabled="exportButton"
            :title="$t('message.prompt')"
            ref="downloadRef"
            :data="exportResult"
        ></edu-export-dialog>
    </div>
</template>
<script>
import externalExchangeApi from 'common/src/api/externalExchange/externalExchange'
import goAbroadForApply from './goAbroadForApply'
import goAbroadForSelect from './goAbroadForSelect'
import goAbroadForEdit from './goAbroadForEdit'
import returnHomeAdd from './returnHomeAdd'
import returnHomeEdit from './returnHomeEdit'
import returnHomeSelect from './returnHomeSelect'
export default {
    components: {
        'go-abroad-for-apply': goAbroadForApply,
        'go-abroad-for-select': goAbroadForSelect,
        'go-abroad-for-edit': goAbroadForEdit,
        'return-home-add': returnHomeAdd,
        'return-home-edit': returnHomeEdit,
        'return-home-select': returnHomeSelect
    },
    // D:\tongjidev\eduweb\src\views\externalExchange\exchangeProjectApp\returnHomeSelect.vue
    data() {
        return {
            auths: [],
            indexKey: 1,
            applyId: '',
            tabTitle: '',
            backId: '',
            permitToBatchPass: true,
            permitToBatchPassManage: true,
            projectSubCategory: 0,
            permitToApply: true,
            permitToDeleteChoosed: true,
            permitToSelectGoAbroad: true,
            permitToEditGoAbroad: true,
            permitToDeleteGoAbroad: true,
            permitToRevokeGoAbroad: true,
            permitToSelectReturnHomeBD: true,
            permitToAddReturnHomeBD: true,
            permitToEditReturnHomeBD: true,
            permitToSelectReturnHomeBX: true,
            permitToAddReturnHomeBX: true,
            permitToEditReturnHomeBX: true,
            permitToRevokeReturnHomeBX: true,
            dialogVisible: false,
            multipleSelection: [],
            queryForm: {
                pageNum_: 1,
                pageSize_: 20,
                total_: 0,
                condition: {}
            },
            dialogMode: 'add',
            dataList: [],
            exportButton: false,
            exportResult: null,
            showProcess: false
        }
    },
    filters: {
        enableStatus(val) {
            switch (val) {
                case 1:
                    return '启用'
                case 0:
                    return '停用'
                default:
                    return val
            }
        },
        goAbroadAuditStatus(val) {
            switch (val) {
                case 0:
                    return '不通过'
                case 1:
                    return '草稿'
                case 2:
                    return '已提交'
                case 3:
                    return '待审核'
                case 4:
                    return '通过'
                case 5:
                    return '驳回'
                default:
                    return val
            }
        },
        getApplyStatusType(val) {
            switch (val) {
                case 0:
                    return 'danger'
                case 1:
                    return 'info'
                case 2:
                    return 'info'
                case 3:
                    return 'info'
                case 4:
                    return 'success'
                case 5:
                    return 'warning'
                case 6:
                    return 'success'
                default:
                    return val
            }
        },
        getAdmissionType(val) {
            switch (val) {
                case 1:
                    return 'success'
                case 2:
                    return 'info'
                case 3:
                    return 'info'
                default:
                    return ''
            }
        },
        returnHomeReimbursement(val) {
            switch (val) {
                case 1:
                    return '草稿'
                case 2:
                    return '已提交'
                case 3:
                    return '待审核'
                case 4:
                    return '通过'
                case 5:
                    return '驳回'
                case 6:
                    return '已完成'
                default:
                    return val
            }
        },
        participantPass(val) {
            switch (val) {
                case 1:
                    return '是'
                case 2:
                    return '否'
                case 3:
                    return '否'
            }
        }
    },
    created() {
        // 获取当前用户auths权限
        if (localStorage.getItem('sessiondata')) {
            if (JSON.parse(localStorage.getItem('sessiondata')).auths) {
                this.auths = JSON.parse(localStorage.getItem('sessiondata')).auths
            }
        }
        this.onSubmit()
    },
    methods: {
        // 校验特殊字符$
        checkSpecial(rule, value, callback) {
            let regEn = /[`$]/im
            if (regEn.test(value)) {
                callback(new Error(this.$t('graduateBase.specialText')))
            } else {
                callback()
            }
        },
        reset() {
            Object.keys(this.queryForm.condition).forEach(
                key => (this.queryForm.condition[key] = '')
            )
            this.onSubmit()
        },
        getListData() {
            externalExchangeApi.getProjectApplicationList(this.queryForm).then(res => {
                this.dataList = res.data.list
                this.queryForm.total_ = res.data.total_
            })
        },
        onSubmit() {
            this.queryForm.pageNum_ = 1
            this.getListData()
        },
        handleSelectionChange(val) {
            this.multipleSelection = val
        },
        handleSizeChange(val) {
            this.queryForm.pageSize_ = val
            this.getListData()
        },
        handleCurrentChange(val) {
            this.queryForm.pageNum_ = val
            this.getListData()
        },
        // 学生申请交流
        stuApplyCommunicate() {
            externalExchangeApi.checkExistsFailedCourse().then(res => {
                if (res.code === 200) {
                    if (res.data.studentExistFailed) {
                        this.$confirm(
                            this.$t('externamExchangeBase.unqualifiedReminder'),
                            this.$t('externamExchangeBase.prompt'),
                            {
                                confirmButtonText: this.$t('externamExchangeBase.confirm'),
                                cancelButtonText: this.$t('externamExchangeBase.cancel'),
                                type: 'warning'
                            }
                        ).then(() => {
                            this.indexKey = 2
                        })
                    } else {
                        this.indexKey = 2
                    }
                }
            })
        },
        // 批量删除数据
        stuDeleteChooseInfo() {
            if (this.multipleSelection.length > 0) {
                let deleteArray = []
                // 出国：非草稿或驳回状态(仅出国有删除)
                let goAbroadStatus = true
                this.multipleSelection.map(value => {
                    if (value.applyStatus === 1 || value.applyStatus === 5) {
                        deleteArray.push(value.applyId)
                    } else {
                        goAbroadStatus = false
                    }
                })
                if (!goAbroadStatus) {
                    this.$message.error(this.$t('externamExchangeBase.deleteTip'))
                } else {
                    this.$delConfirm().then(_ => {
                        externalExchangeApi.deleteProjectApplication(deleteArray).then(res => {
                            if (res.code === 200) {
                                this.$message({
                                    type: 'success',
                                    message: this.$t('externamExchangeBase.operateSuccessfully')
                                })
                                this.onSubmit()
                            }
                        })
                    })
                }
            } else {
                this.$message(this.$t('graduateBase.pleaseChoose'))
            }
        },
        // 回到列表页
        changeProjectIndex() {
            this.indexKey = 1
            this.multipleSelection = []
            this.onSubmit()
        },
        // 出国操作-查看
        selectGoAbroad(row) {
            this.applyId = row.applyId
            this.indexKey = 3
        },
        // 出国操作-编辑
        editGoAbroad(row) {
            this.applyId = row.applyId
            this.indexKey = 4
        },
        // 出国操作-删除
        deleteGoAbroad(row) {
            // 仅可删除草稿、已驳回的出国申请，否则提示不可删除
            this.$delConfirm().then(_ => {
                if (
                    row.applyStatus === 1 ||
                    row.applyStatus === 5 ||
                    (row.back && (row.back.applyStatus === 1 || row.back.applyStatus === 5))
                ) {
                    externalExchangeApi.deleteProjectApplication([row.applyId]).then(res => {
                        if (res.code === 200) {
                            this.$message({
                                type: 'success',
                                message: this.$t('externamExchangeBase.operateSuccessfully')
                            })
                            this.onSubmit()
                        }
                    })
                } else {
                    this.$message.error(this.$t('externamExchangeBase.deleteTip'))
                }
            })
        },
        // 出国操作-撤销
        revokeGoAbroad(row) {
            this.$confirm(
                this.$t('externamExchangeBase.confirmRevoke'),
                this.$t('externamExchangeBase.prompt'),
                {
                    confirmButtonText: this.$t('externamExchangeBase.confirm'),
                    cancelButtonText: this.$t('externamExchangeBase.cancel'),
                    type: 'warning'
                }
            ).then(() => {
                externalExchangeApi
                    .revokeApplyProjectApp({
                        applyId: row.applyId,
                        content: '申请撤销'
                    })
                    .then(res => {
                        if (res.code === 200) {
                            this.$message({
                                type: 'success',
                                message: this.$t('externamExchangeBase.operateSuccessfully')
                            })
                            this.onSubmit()
                        }
                    })
            })
        },
        // 新增回国
        addGoHomeReport(row) {
            this.applyId = row.applyId
            if (row.back) {
                this.backId = row.back.backId
            }
            this.projectSubCategory = row.projectSubCategory
            if (row.changes.length > 0) {
                this.projectStartTime = row.changes[0].projectStartTime
                this.projectEndTime = row.changes[0].projectEndTime
            } else {
                this.projectStartTime = row.projectStartTime
                this.projectEndTime = row.projectEndTime
            }
            this.indexKey = 5
        },
        // 编辑回国
        editReturnHome(row) {
            this.applyId = row.applyId
            this.backId = row.back.backId
            this.projectSubCategory = row.projectSubCategory
            if (row.changes.length > 0) {
                this.projectStartTime = row.changes[0].projectStartTime
                this.projectEndTime = row.changes[0].projectEndTime
            } else {
                this.projectStartTime = row.projectStartTime
                this.projectEndTime = row.projectEndTime
            }
            this.indexKey = 6
        },
        // 撤销回国
        revokeReturnHome(row) {
            this.$confirm(
                this.$t('externamExchangeBase.confirmRevoke'),
                this.$t('externamExchangeBase.prompt'),
                {
                    confirmButtonText: this.$t('externamExchangeBase.confirm'),
                    cancelButtonText: this.$t('externamExchangeBase.cancel'),
                    type: 'warning'
                }
            ).then(() => {
                externalExchangeApi
                    .revokeReturnHomeReimburse({
                        backId: row.back.backId,
                        content: '申请撤销'
                    })
                    .then(res => {
                        if (res.code === 200) {
                            this.$message({
                                type: 'success',
                                message: this.$t('externamExchangeBase.operateSuccessfully')
                            })
                            this.onSubmit()
                        }
                    })
            })
        },

        // 查看回国
        selectReturnHome(row) {
            this.backId = row.back.backId
            if (row.changes.length > 0) {
                this.projectStartTime = row.changes[0].projectStartTime
                this.projectEndTime = row.changes[0].projectEndTime
            } else {
                this.projectStartTime = row.projectStartTime
                this.projectEndTime = row.projectEndTime
            }
            this.tabTitle =
                row.projectSubCategory === 6
                    ? this.$t('projectApplication.nationGovernGoHomeReportSelect')
                    : this.$t('projectApplication.shortTermVisitRuturnGovernSelect')
            if (row.projectSubCategory === 6) {
                this.showProcess = false
            } else {
                this.showProcess = true
            }
            this.indexKey = 7
        }
    },
    watch: {
        auths: {
            handler(newVal) {
                if (newVal && Array.isArray(newVal) && newVal.length > 0) {
                    newVal.some(item => {
                        // 申请（出国）
                        if (item.authCode === 'internCommuni-go-abroad-apply') {
                            this.permitToApply = true
                        }
                        // 删除出国+回国
                        if (item.authCode === 'internCommuni-apply-project-delete') {
                            this.permitToDeleteChoosed = true
                        }
                        // 删除出国
                        if (item.authCode === 'internCommuni-go-abroad-delete') {
                            this.permitToDeleteGoAbroad = true
                        }
                        // 查看出国
                        if (item.authCode === 'internCommuni-go-abroad-select') {
                            this.permitToSelectGoAbroad = true
                        }
                        // 撤销（出国）
                        if (item.authCode === 'internCommuni-go-abroad-turnDown') {
                            this.permitToRevokeGoAbroad = true
                        }
                        // 编辑（出国）
                        if (item.authCode === 'internCommuni-go-abroad-edit') {
                            this.permitToEditGoAbroad = true
                        }
                        // 新增（回国报道）
                        if (item.authCode === 'innternComuni-returnHome-baodao-add') {
                            this.permitToAddReturnHomeBD = true
                        }
                        // 编辑（回国报道）
                        if (item.authCode === 'internCommuni-returnHome-baodao-edit') {
                            this.permitToEditReturnHomeBD = true
                        }
                        // 查看（回国报道）
                        if (item.authCode === 'internCommuni-returnHome-baodao-select') {
                            this.permitToSelectReturnHomeBD = true
                        }
                        // 申请（回国报销）
                        if (item.authCode === 'internCommuni-returnHome-baoxiao-apply') {
                            this.permitToAddReturnHomeBX = true
                        }
                        // 查看（回国报销）
                        if (item.authCode === 'internCommuni-returnHome-baoxiao-select') {
                            this.permitToSelectReturnHomeBX = true
                        }
                        // 撤销（回国报销）
                        if (item.authCode === 'internCommuni-returnHome-baoxiao-turnDown') {
                            this.permitToRevokeReturnHomeBX = true
                        }
                        // 编辑（回国报销）
                        if (item.authCode === 'internCommuni-returnHome-baoxiao-edit') {
                            this.permitToEditReturnHomeBX = true
                        }

                        // 非管理员的通过
                        if (item.authCode === 'internCommuni-project-audit-pass') {
                            this.permitToBatchPass = true
                        }

                        // 管理员的通过
                        if (item.authCode === 'internCommuni-project-audit-pass-manager') {
                            this.permitToBatchPassManage = true
                        }
                    })
                }
            },
            deep: true,
            immediate: true
        }
    }
}
</script>
<style lang="scss" scoped>
.condition-title {
    color: #2b3b4e;
    font-size: 18px;
    line-height: 24px;
    font-weight: bold;
}
.sub-title {
    margin: 16px 0;
    font-size: 16px;
    color: #000020;
    letter-spacing: 0;
}
.project-application-container ::v-deep {
    .el-dialog__body {
        word-break: break-all !important;
    }
}
</style>
